package com.shopmall.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class JumpConfig implements WebMvcConfigurer {  //视图跳转


    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/index").setViewName("login");
        registry.addViewController("/index.html").setViewName("login");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/home1").setViewName("home1"); //后面的参数是实际跳到的视图名，前面参数是在地址栏输入
        registry.addViewController("/hello").setViewName("white");
        registry.addViewController("/abc").setViewName("login0");
    }

    @Override
     public void addResourceHandlers(ResourceHandlerRegistry registry) {  //放行静态资源
        //registry.addResourceHandler("/static/").addResourceLocations("classpath:/static/");
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
